Skip to content

Clean docs and add Plausible tracking#2

Merged
pc-style merged 3 commits into
mainfrom
thread/T-019f25c9-6992-767a-95b0-ae59792f6e84
Jul 3, 2026
Merged

Clean docs and add Plausible tracking#2
pc-style merged 3 commits into
mainfrom
thread/T-019f25c9-6992-767a-95b0-ae59792f6e84

Conversation

@pc-style

@pc-style pc-style commented Jul 3, 2026

Copy link
Copy Markdown
Owner

Summary

  • move active docs into docs/ and archive historical prompts/handoff notes
  • add env-gated Plausible NPM tracker initialization for postwork.pcstyle.dev
  • update README/agent guidance for Vercel, Plausible, and current docs

Verification

  • bun run build

Summary by cubic

Reorganized docs under docs/ and archived historical notes. Added optional, env-gated Plausible Analytics for the demo domain with safe, idempotent, browser-only init; updated Vercel build/deploy guidance.

  • New Features

    • Added @plausible-analytics/tracker (package entrypoint) with outbound link tracking; initializes only in the browser when VITE_PLAUSIBLE_DOMAIN is set.
    • Startup is guarded to avoid SSR errors and double-init; failures never block app load.
    • New src/analytics.ts imported in src/main.tsx; added VITE_PLAUSIBLE_DOMAIN typing in src/vite-env.d.ts.
    • Updated docs links to docs/product.md and docs/design.md; added docs/next.md. Extended .env.local.example.
  • Migration

    • Vercel: set VITE_PLAUSIBLE_DOMAIN=postwork.pcstyle.dev, add that domain under Project → Domains, redeploy, then verify in Plausible.
    • Use build command: bunx convex deploy --cmd-url-env-var-name VITE_CONVEX_URL --cmd 'bun run build' (do not set VITE_CONVEX_URL manually).
    • Local (optional): add VITE_PLAUSIBLE_DOMAIN in .env.local.

Written for commit d705f4c. Summary will update on new commits.

Review in cubic

@vercel

vercel Bot commented Jul 3, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
better-slack Ready Ready Preview, Comment Jul 3, 2026 10:17am

@socket-security

socket-security Bot commented Jul 3, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Added@​plausible-analytics/​tracker@​0.4.5961009987100

View full report

@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This PR adds Plausible Analytics integration, wires it into app startup, updates Vite/type support for the tracker and env var, and revises deployment notes and roadmap docs.

Changes

Plausible Analytics Integration

Layer / File(s) Summary
Analytics initialization and build support
package.json, vite.config.ts, src/vite-env.d.ts, src/analytics.ts, src/main.tsx
Adds the Plausible tracker dependency, aliases the tracker package for Vite, defines VITE_PLAUSIBLE_DOMAIN types, conditionally initializes analytics with one-time browser startup logic, and imports the module at app launch.
Deployment and environment configuration docs
.env.local.example, README.md, AGENTS.md
Documents the optional Plausible domain setting, the Vercel build-time Convex URL injection, required environment variables, and Plausible domain verification steps.
Design reference and roadmap doc updates
AGENTS.md, docs/next.md
Updates design reference pointers and visual quick-reference notes, and adds the Next roadmap content.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant MainTsx as main.tsx
  participant AnalyticsModule as analytics.ts
  participant PlausibleTracker as `@plausible-analytics/tracker`

  MainTsx->>AnalyticsModule: import ./analytics
  AnalyticsModule->>AnalyticsModule: read VITE_PLAUSIBLE_DOMAIN
  alt domain is set and window exists
    AnalyticsModule->>PlausibleTracker: init({ domain, outboundLinks: true })
  else domain is missing or init already ran
    AnalyticsModule-->>MainTsx: no-op
  end
Loading

Poem

A bunny booted up the site with cheer,
Then tracked a tiny trail from far and near 🐇
The docs were tidied, the domains aligned,
And roadmap carrots neatly intertwined.
Hops, builds, and aliases all in place—
This rabbit nods with a happy face.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the main changes: docs cleanup and Plausible tracking integration.
Description check ✅ Passed The description is directly related to the documented doc reorganization and Plausible/Vercel updates.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch thread/T-019f25c9-6992-767a-95b0-ae59792f6e84
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch thread/T-019f25c9-6992-767a-95b0-ae59792f6e84

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/analytics.ts (1)

1-10: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Guard init() so a tracker failure can't break app startup.

analytics.ts is imported before createRoot(...).render(...) in main.tsx. If init() throws (misconfigured domain, packaging/resolution issue, browser API unavailability), it aborts module evaluation and the whole app fails to mount, for what is purely an optional analytics feature.

🛡️ Proposed fix
 const plausibleDomain = import.meta.env.VITE_PLAUSIBLE_DOMAIN;

 if (plausibleDomain) {
-  init({
-    domain: plausibleDomain,
-    outboundLinks: true,
-  });
+  try {
+    init({
+      domain: plausibleDomain,
+      outboundLinks: true,
+    });
+  } catch {
+    // analytics is best-effort; never block app startup
+  }
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/analytics.ts` around lines 1 - 10, `analytics.ts` currently calls
`init()` during module evaluation, so any tracker failure can stop app startup
before `main.tsx` reaches `createRoot(...).render(...)`. Wrap the `init()` call
in a narrow try/catch (or move it into a safe bootstrap helper) so optional
analytics errors are swallowed or logged without aborting app mount, and keep
the guard tied to `plausibleDomain` in `analytics.ts`.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@package.json`:
- Line 21: The dependency pin for `@plausible-analytics/tracker` is still on
0.4.5, which is the version affected by the Vite entry-resolution issue. Update
the version in package.json to a release that includes the exports fix, and make
sure src/analytics.ts continues to import the package at module scope without
triggering the bug.

---

Nitpick comments:
In `@src/analytics.ts`:
- Around line 1-10: `analytics.ts` currently calls `init()` during module
evaluation, so any tracker failure can stop app startup before `main.tsx`
reaches `createRoot(...).render(...)`. Wrap the `init()` call in a narrow
try/catch (or move it into a safe bootstrap helper) so optional analytics errors
are swallowed or logged without aborting app mount, and keep the guard tied to
`plausibleDomain` in `analytics.ts`.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 06bba33e-c715-48d2-8279-0e17239fe57a

📥 Commits

Reviewing files that changed from the base of the PR and between 2d60cc3 and c52c645.

⛔ Files ignored due to path filters (1)
  • bun.lock is excluded by !**/*.lock
📒 Files selected for processing (14)
  • .env.local.example
  • AGENTS.md
  • NEXT.md
  • README.md
  • docs/archive/flash-experiments-handoff-2026-06-29.md
  • docs/archive/initial-mvp-prompt.md
  • docs/archive/theo-team-communication-brief.md
  • docs/design.md
  • docs/next.md
  • docs/product.md
  • package.json
  • src/analytics.ts
  • src/main.tsx
  • src/vite-env.d.ts
💤 Files with no reviewable changes (1)
  • NEXT.md

Comment thread package.json

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 15 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread package.json
Comment thread src/analytics.ts Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
vite.config.ts (1)

4-16: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use the package specifier here instead of a deep node_modules path. @plausible-analytics/tracker already exposes a normal entrypoint, so this alias can just resolve the package itself. That keeps the config independent of the package’s internal file layout and avoids a future break if the published artifact path changes.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@vite.config.ts` around lines 4 - 16, The Vite alias for
`@plausible-analytics/tracker` is pointing to a deep node_modules file path
instead of the package entrypoint. Update the alias setup in vite.config.ts so
the `@plausible-analytics/tracker` specifier resolves directly to the package name
rather than using fileURLToPath/new URL for plausible.js, keeping the config
tied to the public package API.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@vite.config.ts`:
- Around line 4-16: The Vite alias for `@plausible-analytics/tracker` is pointing
to a deep node_modules file path instead of the package entrypoint. Update the
alias setup in vite.config.ts so the `@plausible-analytics/tracker` specifier
resolves directly to the package name rather than using fileURLToPath/new URL
for plausible.js, keeping the config tied to the public package API.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1ca7b767-f8b1-453a-8256-930ef067e1ec

📥 Commits

Reviewing files that changed from the base of the PR and between c52c645 and 9a14f8e.

📒 Files selected for processing (2)
  • src/analytics.ts
  • vite.config.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/analytics.ts

@pc-style
pc-style merged commit 74a5003 into main Jul 3, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants